<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="8" :lg="11" :md="12" :sm="24">
            <a-form-item label="创建日期">
              <j-date
                date-format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择开始时间"
                class="query-group-cust"
                v-model="queryParam.createTime_begin"
                :show-time="true"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                date-format="YYYY-MM-DD HH:mm:ss"
                placeholder="请选择结束时间"
                class="query-group-cust"
                v-model="queryParam.createTime_end"
                :show-time="true"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="8" :lg="11" :md="12" :sm="24">
            <a-form-item label="回复时间">
              <j-date
                placeholder="请选择开始日期"
                class="query-group-cust"
                date-format="YYYY-MM-DD HH:mm:ss"
                :show-time="true"
                v-model="queryParam.replyTime_begin"
              ></j-date>
              <span class="query-group-split-cust"></span>
              <j-date
                placeholder="请选择结束日期"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                class="query-group-cust"
                v-model="queryParam.replyTime_end"
              ></j-date>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="消息来源（群）">
              <a-input placeholder="请输入消息来源（群）" v-model="queryParam.msgGroup"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客户名称">
              <a-input placeholder="请输入客户名称" v-model="queryParam.customerName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客户消息内容">
              <a-input placeholder="请输入客户消息内容" v-model="queryParam.msgText"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="大类">
              <j-dict-select-tag
                v-model="queryParam.category"
                placeholder="请选择大类"
                dictCode="gjzdl"
                style="width:100%"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="消息类型">
              <j-dict-select-tag
                v-model="queryParam.msgtype"
                placeholder="请选择消息类型"
                dictCode="gjzinfotype"
                style="width:100%"
              />
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="订单号">
              <a-input placeholder="请输入订单号" v-model="queryParam.orderNo"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="快递单号">
              <a-input placeholder="请输入快递单号" v-model="queryParam.trackingNumber"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="供应商回复内容">
              <a-input placeholder="请输入供应商回复内容" v-model="queryParam.supplierReply"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="确认回复内容">
              <a-input placeholder="请输入确认回复内容" v-model="queryParam.comfirmReply"></a-input>
            </a-form-item>
          </a-col>

          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="回复人">
              <a-input placeholder="请输入回复人" v-model="queryParam.replyer"></a-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="是否完成">
              <a-select placeholder="请选择是否完成" v-model="queryParam.isComplete" allowClear>
                <a-select-option value="是">是</a-select-option>
                <a-select-option value="否">否</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="处理状态">
              <a-select placeholder="请选择处理状态" v-model="queryParam.taskState" allowClear>
                <a-select-option value="已处理">已处理</a-select-option>
                <a-select-option value="未处理">未处理</a-select-option>
                <a-select-option value="人工介入">人工介入</a-select-option>
                <a-select-option value="处理中">处理中</a-select-option>
                <a-select-option value="被拆分">被拆分</a-select-option>
                <a-select-option value="多订单拆分">多订单拆分</a-select-option>
                <a-select-option value="机器人处理中">机器人处理中</a-select-option>
                <a-select-option value="机器人已处理">机器人已处理</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <a-form-item label="客服">
              <a-select placeholder="请选择客服" v-model="queryParam.customerService" allowClear>
                <a-select-option :value="item.username" v-for="(item, index) in kefuNameList" :key="index">{{
                  item.username
                }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <!-- <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button> -->
      <a-button type="primary" icon="download" @click="handleExportXls('任务列表')">导出</a-button>
      <!-- <a-upload
        name="file"
        :showUploadList="false"
        :multiple="false"
        :headers="tokenHeader"
        :action="importExcelUrl"
        @change="handleImportExcel"
      >
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload> -->
      <!-- 高级查询区域 -->
      <j-super-query
        :fieldList="superFieldList"
        ref="superQueryModal"
        @handleSuperQuery="handleSuperQuery"
      ></j-super-query>

      <a-button type="primary" @click="doconfirm">批量完成</a-button>
      <a-button type="primary" @click="plzhuanfa">批量转发</a-button>

      <!-- <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete" />删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down"/></a-button>
      </a-dropdown> -->
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        <!-- <span style="float:right;">
          <a-popover title="自定义列" trigger="click" placement="leftBottom">
            <template slot="content">
              <a-checkbox-group @change="onColSettingsChange" v-model="settingColumns" :defaultValue="settingColumns">
                <a-row style="width: 400px">
                  <template v-for="(item, index) in defColumns">
                    <template v-if="item.key != 'rowIndex' && item.dataIndex != 'action'">
                      <a-col :span="12" :key="index"
                        ><a-checkbox :value="item.dataIndex"
                          ><j-ellipsis :value="item.title" :length="10"></j-ellipsis></a-checkbox
                      ></a-col>
                    </template>
                  </template>
                </a-row>
              </a-checkbox-group>
            </template>
            <a><a-icon type="setting" />设置</a>
          </a-popover>
        </span> -->
      </div>

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: '100%' }"
        bordered
        rowKey="id"
        :columns="defColumns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange"
        :customRow="customRow"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }"
      >
        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width:80px;font-size: 12px;font-style: italic;"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button v-else :ghost="true" type="primary" icon="download" size="small" @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <template slot="isComplete" slot-scope="text">
          <a-tag color="green" v-if="text == '是'">是</a-tag>
          <a-tag color="red" v-if="text == '否'">否</a-tag>
        </template>
        <template slot="taskState" slot-scope="text, record">
          <a-tag color="green" v-if="text == '已处理'">已处理</a-tag>
          <a-tag color="blue" v-if="text == '处理中'">处理中</a-tag>
          <a-tag color="orange" v-if="text == '人工介入'" @click="dopeoplejr(record)">人工介入</a-tag>
          <a-tag color="red" v-if="text == '未处理'">未处理</a-tag>
          <a-tag color="pink" v-if="text == '被拆分'">被拆分</a-tag>
          <a-tag color="purple" v-if="text == '多订单拆分'">多订单拆分</a-tag>
          <a-tag color="cyan" v-if="text == '机器人处理中'">机器人处理中</a-tag>
          <a-tag color="green" v-if="text == '机器人已处理'">机器人已处理</a-tag>
        </template>
        <template slot="msgText" slot-scope="text, record">
          <span
            :title="record.msgText"
            style="width: 100%;"
            :id="'msgText' + record.id"
            @dblclick="domsgText(record)"
            >{{ text }}</span
          >
        </template>
        <template slot="supplierReply" slot-scope="text, record">
          <span :title="record.supplierReply" :id="'supplierReply' + record.id" @dblclick="dosupplierReply(record)">{{
            text
          }}</span>
        </template>
        <template slot="comfirmReply" slot-scope="text, record">
          <span :title="record.comfirmReply" :id="'comfirmReply' + record.id" @dblclick="docomfirmReply(record)">{{
            text
          }}</span>
        </template>
        <template slot="trackingNumber" slot-scope="text, record">
          <span
            :title="record.trackingNumber"
            :id="'trackingNumber' + record.id"
            @dblclick="dotrackingNumber(record)"
            >{{ text }}</span
          >
        </template>
        <template slot="orderNo" slot-scope="text, record">
          <span :title="record.orderNo" :id="'orderNo' + record.id" @dblclick="doorderNo(record)">{{ text }}</span>
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down"/></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="dopeoplejr(record)">人工介入</a>
              </a-menu-item>
              <a-menu-item>
                <a @click="zhuanfa(record)">转发</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定完成吗?" @confirm="() => handlewancheng(record.id)">
                  <a>完成</a>
                </a-popconfirm>
              </a-menu-item>
              <a-menu-item>
                <a rel="nofollow" href="wxwork://message?uin=1688850522843493&amp;source=100">打开企业微信</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>

    <tasklsit-modal ref="modalForm" @ok="modalFormOk"></tasklsit-modal>
    <peoplejr ref="peoplejr" @rengongok="rengongok"></peoplejr>
    <a-modal v-model="zhuanfaShow" width="400px" title="转发" @cancel="zhuanfaShow = false" @ok="zhuanfaOk">
      <a-row>
        <a-col :span="24">
          <a-form-model-item label="客服名字" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select style="width: 100%" placeholder="请选择客服名字" v-model="kefuName" allowClear>
              <a-select-option :value="item.username" v-for="(item, index) in kefuNameList" :key="index">{{
                item.username
              }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-modal>
    <a-modal v-model="plzhuanfaShow" width="400px" title="批量转发" @cancel="plzhuanfaShow = false" @ok="plzhuanfaOk">
      <a-row>
        <a-col :span="24">
          <a-form-model-item label="客服名字" :labelCol="labelCol" :wrapperCol="wrapperCol">
            <a-select style="width: 100%" placeholder="请选择客服名字" v-model="plkefuName" allowClear>
              <a-select-option :value="item.username" v-for="(item, index) in kefuNameList" :key="index">{{
                item.username
              }}</a-select-option>
            </a-select>
          </a-form-model-item>
        </a-col>
      </a-row>
    </a-modal>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import TasklsitModal from './modules/TasklsitModal'
import peoplejr from './modules/peoplejr.vue'
import Vue from 'vue'
import dayjs from 'dayjs'
import { httpAction, getAction, postAction, putAction } from '@/api/manage'
import Sortable from 'sortablejs'

export default {
  name: 'TasklsitList',
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    TasklsitModal,
    peoplejr
  },
  data() {
    return {
      description: '任务列表管理页面',
      //表头
      columns: [],
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 }
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 }
      },
      //列设置
      settingColumns: [],
      // 表头
      defColumns: [
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          // fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' }
        },
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function(t, r, index) {
            return parseInt(index) + 1
          }
        },
        {
          title: '客服',
          align: 'center',
          dataIndex: 'customerService',
          width: 140,
          ellipsis: true
        },
        {
          title: '消息来源（群）',
          align: 'center',
          dataIndex: 'msgGroup',
          width: 200,
          ellipsis: true
        },
        {
          title: '库房名称',
          align: 'center',
          dataIndex: 'storeHouse',
          width: 140,
          ellipsis: true
        },
        {
          title: '是否完成',
          align: 'center',
          dataIndex: 'isComplete',
          scopedSlots: { customRender: 'isComplete' },
          width: 140,
          ellipsis: true
        },
        {
          title: '处理状态',
          align: 'center',
          dataIndex: 'taskState',
          scopedSlots: { customRender: 'taskState' },
          width: 140,
          ellipsis: true
        },
        {
          title: '客户名称',
          align: 'center',
          dataIndex: 'customerName',
          width: 140,
          ellipsis: true
        },
        {
          title: '客户消息内容',
          align: 'center',
          dataIndex: 'msgText',
          width: 140,
          ellipsis: true,
          scopedSlots: { customRender: 'msgText' }
        },
        {
          title: '大类',
          align: 'center',
          dataIndex: 'category',
          width: 140,
          ellipsis: true
        },
        {
          title: '消息类型',
          align: 'center',
          dataIndex: 'msgtype',
          width: 140,
          ellipsis: true
        },
        {
          title: '订单号',
          align: 'center',
          dataIndex: 'orderNo',
          width: 200,
          ellipsis: true,
          scopedSlots: { customRender: 'orderNo' }
        },
        {
          title: '快递单号',
          align: 'center',
          dataIndex: 'trackingNumber',
          width: 220,
          ellipsis: true,
          scopedSlots: { customRender: 'trackingNumber' }
        },
        {
          title: '供应商回复内容',
          align: 'center',
          dataIndex: 'supplierReply',
          width: 140,
          ellipsis: true,
          scopedSlots: { customRender: 'supplierReply' }
        },
        {
          title: '确认回复内容',
          align: 'center',
          dataIndex: 'comfirmReply',
          width: 140,
          ellipsis: true,
          scopedSlots: { customRender: 'comfirmReply' }
        },
        {
          title: '回复时间',
          align: 'center',
          dataIndex: 'replyTime',
          width: 140,
          ellipsis: true
        },
        {
          title: '回复人',
          align: 'center',
          dataIndex: 'replyer',
          width: 140,
          ellipsis: true
        },
        {
          title: '完结人',
          align: 'center',
          dataIndex: 'completePlayer',
          width: 140,
          ellipsis: true
        },
        {
          title: '创建日期',
          align: 'center',
          dataIndex: 'createTime',
          width: 180,
          ellipsis: true
        }
      ],
      url: {
        list: '/tasklsit/tasklsit/list',
        delete: '/tasklsit/tasklsit/delete',
        deleteBatch: '/tasklsit/tasklsit/deleteBatch',
        exportXlsUrl: '/tasklsit/tasklsit/exportXls',
        importExcelUrl: 'tasklsit/tasklsit/importExcel'
      },
      dictOptions: {},
      superFieldList: [],
      queryParam: {
        createTime_begin: dayjs()
          .subtract(2, 'day')
          .format('YYYY-MM-DD'),
        createTime_end: dayjs()
          .subtract(0, 'day')
          .format('YYYY-MM-DD')
      },
      zhuanfaShow: false,
      kefuName: '',
      kefuId: '',
      kefuNameList: [],
      plzhuanfaShow: false,
      plkefuName: '',
      userInfo: this.$store.getters.userInfo
    }
  },
  created() {
    // this.initColumns()
    this.getSuperFieldList()
    this.getkefuName()
    // setTimeout(() => {
    //   this.columnDrag()
    // }, 1000)
    this.$nextTick(() => {
      this.columnDrag()
    })
  },
  mounted() {},
  computed: {
    importExcelUrl: function() {
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
    }
  },
  methods: {
    domsgText(r) {
      if (r.msgText) {
        this.$notification.open({
          message: '客户消息内容',
          description: r.msgText
        })
        let msgTextinfo = document.querySelector(`#msgText${r.id}`)
        var textArea = document.createElement('textarea')
        textArea.value = msgTextinfo.textContent
        document.body.appendChild(textArea)
        textArea.select()
        document.execCommand('Copy')
        textArea.remove()
        this.$message.success('复制成功')
      }
    },
    dosupplierReply(r) {
      if (r.supplierReply) {
        this.$notification.open({
          message: '供应商回复内容',
          description: r.supplierReply
        })
        let supplierReplyinfo = document.querySelector(`#supplierReply${r.id}`)
        var textArea = document.createElement('textarea')
        textArea.value = supplierReplyinfo.textContent
        document.body.appendChild(textArea)
        textArea.select()
        document.execCommand('Copy')
        textArea.remove()
        this.$message.success('复制成功')
      }
    },
    docomfirmReply(r) {
      if (r.comfirmReply) {
        this.$notification.open({
          message: '确认回复内容',
          description: r.comfirmReply
        })
        let comfirmReplyinfo = document.querySelector(`#comfirmReply${r.id}`)
        var textArea = document.createElement('textarea')
        textArea.value = comfirmReplyinfo.textContent
        document.body.appendChild(textArea)
        textArea.select()
        document.execCommand('Copy')
        textArea.remove()
        this.$message.success('复制成功')
      }
    },
    dotrackingNumber(r) {
      if (r.trackingNumber) {
        this.$notification.open({
          message: '快递单号',
          description: r.trackingNumber
        })
        let trackingNumberinfo = document.querySelector(`#trackingNumber${r.id}`)
        var textArea = document.createElement('textarea')
        textArea.value = trackingNumberinfo.textContent
        document.body.appendChild(textArea)
        textArea.select()
        document.execCommand('Copy')
        textArea.remove()
        this.$message.success('复制成功')
      }
    },
    doorderNo(r) {
      if (r.orderNo) {
        this.$notification.open({
          message: '订单号',
          description: r.orderNo
        })
        let orderNoinfo = document.querySelector(`#orderNo${r.id}`)
        var textArea = document.createElement('textarea')
        textArea.value = orderNoinfo.textContent
        document.body.appendChild(textArea)
        textArea.select()
        document.execCommand('Copy')
        textArea.remove()
        this.$message.success('复制成功')
      }
    },
    columnDrag() {
      // 获取table表头
      var el = document.querySelector('.ant-table-thead tr')
      let filterNum = 0
      // 选择框列不计算sortable 获取的index要减去选择框1列
      let selection = el.querySelector('.ant-table-selection-column')
      if (selection) {
        filterNum++
      }
      // draggable 指定那些元素可以被拖拽
      var sortable = Sortable.create(el, {
        animation: 150,
        draggable: '.ant-table-align-center,.ant-table-align-left',
        onEnd: evt => {
          var oldColumn = this.defColumns[evt.oldIndex - filterNum]
          this.defColumns.splice(evt.oldIndex - filterNum, 1)
          this.defColumns.splice(evt.newIndex - filterNum, 0, oldColumn)
        }
      })
    },
    getkefuName() {
      let roleId = '1674324993338867714'
      let url = '/sys/user/userRoleList'
      getAction(url, { roleId }).then(res => {
        if (res.success) {
          this.kefuNameList = res.result.records
        }
      })
    },
    zhuanfa(r) {
      this.zhuanfaShow = true
      this.kefuId = r.id
    },
    zhuanfaOk() {
      if (!this.kefuName) return this.$message.error('客服名字不能为空')
      let url = '/tasklsit/tasklsit/edit'
      let data = {
        id: this.kefuId,
        customerService: this.kefuName
      }
      putAction(url, data).then(res => {
        if (res.success) {
          this.$message.success(res.message)
          this.zhuanfaShow = false
          this.loadData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    handlewancheng(id) {
      let url = '/tasklsit/tasklsit/edit'
      let data = {
        id: id,
        isComplete: '是'
      }
      putAction(url, data).then(res => {
        if (res.success) {
          this.$message.success(res.message)
          this.loadData()
        } else {
          this.$message.error(res.message)
        }
      })
    },
    doconfirm() {
      if (this.selectedRowKeys.length == 0) return this.$message.error('请选择一条数据')
      this.$confirm({
        content: '是否确认完成?',
        onOk: () => {
          let url = '/tasklsit/tasklsit/batchEdit'
          let arr = []
          this.selectedRowKeys.forEach(item => {
            let obj = {
              id: item,
              isComplete: '是'
            }
            arr.push(obj)
          })
          postAction(url, arr).then(res => {
            if (res.success) {
              this.$message.success(res.message)
              this.loadData()
              this.onClearSelected()
            } else {
              this.$message.error(res.message)
            }
          })
        }
      })
    },
    plzhuanfa() {
      this.plzhuanfaShow = true
    },
    plzhuanfaOk() {
      if (this.selectedRowKeys.length == 0) return this.$message.error('请选择一条数据')
      this.$confirm({
        content: '是否确认转发?',
        onOk: () => {
          let url = '/tasklsit/tasklsit/batchEdit'
          let arr = []
          this.selectedRowKeys.forEach(item => {
            let obj = {
              id: item,
              customerService: this.plkefuName
            }
            arr.push(obj)
          })
          postAction(url, arr).then(res => {
            if (res.success) {
              this.$message.success(res.message)
              this.plzhuanfaShow = false
              this.loadData()
              this.onClearSelected()
            } else {
              this.$message.error(res.message)
            }
          })
        }
      })
    },
    customRow(record, index) {
      return {
        style: {
          color: record.msgtype == '催发货' ? 'red' : '#000000A6'
        }
      }
    },
    dopeoplejr(r) {
      this.$refs.peoplejr.init(r)
    },
    rengongok() {
      this.loadData()
    },
    onColSettingsChange(checkedValues) {
      var key = this.$route.name + ':colsettings'
      Vue.ls.set(key, checkedValues, 7 * 24 * 60 * 60 * 1000)
      this.settingColumns = checkedValues
      const cols = this.defColumns.filter(item => {
        if (item.key == 'rowIndex' || item.dataIndex == 'action') {
          return true
        }
        if (this.settingColumns.includes(item.dataIndex)) {
          return true
        }
        return false
      })
      this.columns = cols
    },
    initColumns() {
      //权限过滤（列权限控制时打开，修改第二个参数为授权码前缀）
      //this.defColumns = colAuthFilter(this.defColumns,'testdemo:');

      var key = this.$route.name + ':colsettings'
      let colSettings = Vue.ls.get(key)
      console.log(colSettings)
      if (colSettings == null || colSettings == undefined) {
        let allSettingColumns = []
        this.defColumns.forEach(function(item, i, array) {
          allSettingColumns.push(item.dataIndex)
        })
        this.settingColumns = allSettingColumns
        this.columns = this.defColumns
      } else {
        this.settingColumns = colSettings
        const cols = this.defColumns.filter(item => {
          if (item.key == 'rowIndex' || item.dataIndex == 'action') {
            return true
          }
          if (colSettings.includes(item.dataIndex)) {
            return true
          }
          return false
        })
        this.columns = cols
      }
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = []
      fieldList.push({ type: 'datetime', value: 'createTime', text: '创建日期' })
      fieldList.push({ type: 'string', value: 'msgGroup', text: '消息来源（群）', dictCode: '' })
      fieldList.push({ type: 'string', value: 'storeHouse', text: '库房名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'customerName', text: '客户名称', dictCode: '' })
      fieldList.push({ type: 'string', value: 'msgText', text: '客户消息内容', dictCode: '' })
      fieldList.push({ type: 'string', value: 'category', text: '大类', dictCode: '' })
      fieldList.push({ type: 'string', value: 'msgtype', text: '消息类型', dictCode: '' })
      fieldList.push({ type: 'string', value: 'orderNo', text: '订单号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'trackingNumber', text: '快递单号', dictCode: '' })
      fieldList.push({ type: 'string', value: 'supplierReply', text: '供应商回复内容', dictCode: '' })
      fieldList.push({ type: 'string', value: 'comfirmReply', text: '确认回复内容', dictCode: '' })
      fieldList.push({ type: 'date', value: 'replyTime', text: '回复时间' })
      fieldList.push({ type: 'string', value: 'replyer', text: '回复人', dictCode: '' })
      fieldList.push({ type: 'string', value: 'isComplete', text: '是否完成', dictCode: '' })
      fieldList.push({ type: 'string', value: 'taskState', text: '处理状态', dictCode: '' })
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
</style>
